package com.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class DynamicProxy implements InvocationHandler {
	private Object targetObject;		// 代理的目标对象
	
	public DynamicProxy(Object obj) {
		this.targetObject = obj;
	}
	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		System.out.println("before");
		Object obj = method.invoke(this.targetObject, args);// 把方法调用委派给目标对象
		System.out.println("after");
		return obj;
	}


}
